import sys
import time

import pefile

def doLog(msg):
	print "[%s] %s" %(time.ctime(), msg)

def main(filename):
	try:
		pe = pefile.PE(filename, fast_load=True)
	except pefile.PEFormatError:
		doLog("PEFormatError")
		return 0

	if pe.FILE_HEADER.Characteristics & 0x2000 != 0:
		doLog("This is a Dll file")
		return 0
	else:
		return 1

def usage():
	print "Usage:", sys.argv[0], "<PE file>"

if __name__ == "__main__":
	if len(sys.argv) == 1:
		usage()
		sys.exit(1)
	else:
		sys.exit(main(sys.argv[1]))
